@@ -41,45 +41,46 @@ export async function getBreachIcons(breaches: HibpGetBreachesResponse) {
41
41
// read existing logos
42
42
const existingLogos = await readdir ( logoFolder ) ;
43
43
44
- await Promise . allSettled (
45
- breaches . map ( async ( { Domain : breachDomain , Name : breachName } ) => {
46
- if ( ! breachDomain || breachDomain . length === 0 ) {
47
- console . log ( "empty domain: " , breachName ) ;
48
- await updateBreachFaviconUrl ( breachName , null ) ;
49
- return ;
50
- }
51
- const logoFilename = breachDomain . toLowerCase ( ) + ".ico" ;
52
- if ( existingLogos . includes ( logoFilename ) ) {
53
- console . log ( "skipping " , logoFilename ) ;
54
- await updateBreachFaviconUrl (
55
- breachName ,
56
- `https://s3.amazonaws.com/${ process . env . S3_BUCKET } /${ logoFilename } ` ,
57
- ) ;
58
- return ;
59
- }
60
- console . log ( `fetching: ${ logoFilename } ` ) ;
61
- const res = await fetch (
62
- `https://icons.duckduckgo.com/ip3/${ breachDomain } .ico` ,
44
+ for ( const breach of breaches ) {
45
+ const breachDomain = breach . Domain
46
+ const breachName = breach . Name
47
+
48
+ if ( ! breachDomain || breachDomain . length === 0 ) {
49
+ console . log ( "empty domain: " , breachName ) ;
50
+ await updateBreachFaviconUrl ( breachName , null ) ;
51
+ return ;
52
+ }
53
+ const logoFilename = breachDomain . toLowerCase ( ) + ".ico" ;
54
+ if ( existingLogos . includes ( logoFilename ) ) {
55
+ console . log ( "skipping " , logoFilename ) ;
56
+ await updateBreachFaviconUrl (
57
+ breachName ,
58
+ `https://s3.amazonaws.com/${ process . env . S3_BUCKET } /${ logoFilename } ` ,
63
59
) ;
64
- if ( res . status !== 200 ) {
65
- // update logo path with null
66
- console . log ( `Logo does not exist for: ${ breachName } ${ breachDomain } ` ) ;
67
- await updateBreachFaviconUrl ( breachName , null ) ;
68
- return ;
69
- }
70
-
71
- try {
72
- await uploadToS3 ( logoFilename , Buffer . from ( await res . arrayBuffer ( ) ) ) ;
73
- await updateBreachFaviconUrl (
74
- breachName ,
75
- `https://s3.amazonaws.com/${ process . env . S3_BUCKET } /${ logoFilename } ` ,
76
- ) ;
77
- } catch ( e ) {
78
- console . error ( e ) ;
79
- return ;
80
- }
81
- } ) ,
82
- ) ;
60
+ return ;
61
+ }
62
+ console . log ( `fetching: ${ logoFilename } ` ) ;
63
+ const res = await fetch (
64
+ `https://icons.duckduckgo.com/ip3/${ breachDomain } .ico` ,
65
+ ) ;
66
+ if ( res . status !== 200 ) {
67
+ // update logo path with null
68
+ console . log ( `Logo does not exist for: ${ breachName } ${ breachDomain } ` ) ;
69
+ await updateBreachFaviconUrl ( breachName , null ) ;
70
+ return ;
71
+ }
72
+
73
+ try {
74
+ await uploadToS3 ( logoFilename , Buffer . from ( await res . arrayBuffer ( ) ) ) ;
75
+ await updateBreachFaviconUrl (
76
+ breachName ,
77
+ `https://s3.amazonaws.com/${ process . env . S3_BUCKET } /${ logoFilename } ` ,
78
+ ) ;
79
+ } catch ( e ) {
80
+ console . error ( e ) ;
81
+ return ;
82
+ }
83
+ }
83
84
}
84
85
85
86
// Get breaches and upserts to DB
0 commit comments